﻿Imports System.Text.RegularExpressions
Public Class PageForm

    Private _bClose As Boolean = False
    Public Property BClose() As Boolean
        Get
            Return _bClose
        End Get
        Set(ByVal value As Boolean)
            _bClose = True
        End Set
    End Property
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        _bClose = True
        Me.Close()
    End Sub

#Region "开始页"
    Public Property GetStartPage() As Integer
        Get
            Return CType(Me.txtStartPage.Text, Integer)
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property
#End Region

#Region "结束页"
    Public Property GetEndtPage() As Integer
        Get
            Return CType(Me.txtEndPage.Text, Integer)
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property
#End Region

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

        If Not IsNumeric(Me.txtStartPage.Text) Then
            Me.txtStartPage.Text = ""
            Me.txtStartPage.Focus()
            Exit Sub
        End If

        If Not IsNumeric(Me.txtEndPage.Text) Then
            Me.txtEndPage.Text = ""
            Me.txtEndPage.Focus()
            Exit Sub
        End If

        If CType(Me.txtStartPage.Text, Integer) > CType(Me.txtEndPage.Text, Integer) Then
            Me.txtEndPage.Text = ""
            Me.txtEndPage.Focus()
            Exit Sub
        End If
        Me.Close()
    End Sub

#Region "只能入力数字 A-2010-03-08"
    Private Sub txtPage_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtStartPage.KeyPress, txtEndPage.KeyPress
        '应许输入退格键 C# 强制转换
        If Asc(e.KeyChar) <> 8 Then
            '正则验证数字
            If (Not Regex.IsMatch(e.KeyChar.ToString(), "^[0-9]$")) Then
                e.Handled = True
                Return
            End If
        End If
    End Sub
#End Region
End Class
